import com.alipay.global.api.tools.SignatureTool;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.util.CollectionUtils;
import typeConversion.typeDo.GoodsListFileInfoBO;
import utils.CollectionUtil;
import 算法.抽奖算法.base.LotteryTurntableBO;


import javax.lang.model.SourceVersion;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @author yangjicong
 * @date 2022/2/26
 */
public class others {

    public static void main(String[] args) throws Exception {
//Multi-threading
        List<String> list =new ArrayList();
        list.add("aaa");
        list.add("bbb");
        list.add("abc");
        list.add("ccc");
        list.add("ddd");

        //Matching
        boolean isValid = list.stream().anyMatch(element -> element.contains("h"));
        boolean isValidOne = list.stream().allMatch(element -> element.contains("h"));
        boolean isValidTwo = list.stream().noneMatch(element -> element.contains("h"));

        System.out.println("isValidTwo = " + isValid);
        System.out.println("isValidTwo = " + isValidOne);
        System.out.println("isValidTwo = " + isValidTwo);



    }


    public static void timeTest2()  {
        Date date = new Date();

        if (date.getTime() > 1664538632000L) {

            System.out.println("date = {}");
        }
        //测试时间1
        String testTimeOne = "2022-10-12 13:09:51";
        //测试时间2
        String testTimeTwo = "2022-10-31 00:00:00";
        //时间格式化
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        try {
            Date start = format.parse(testTimeOne);
            Date end = format.parse(testTimeTwo);

            //现在时间
            Date now = new Date();
            //开始时间
            if (now.after(start) && now.before(end)){
                System.out.println("11111111");
            }
            System.out.println("end = " + end.getTime());


            boolean after = date.before(end);
            System.out.println("after = " + after);
            if (date.after(start) && date.before(end)) {
                System.out.println("after 123123= ");
            }

        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
    /**
     * 反射赋值测试
     */
    public static void reflectionTest() throws IllegalAccessException {
        GoodsListFileInfoBO goodsListFileInfoBO = new GoodsListFileInfoBO();
        Class<GoodsListFileInfoBO> goodsListFileInfoBOClass = GoodsListFileInfoBO.class;
        int cellNum = 0;
        Field[] declaredFields = goodsListFileInfoBOClass.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            declaredField.setAccessible(true);

            declaredField.set(goodsListFileInfoBO, String.valueOf(cellNum));
            cellNum++;
        }
        System.out.println("declaredFields = " + goodsListFileInfoBO);
    }


    public static void phoneTest() {
        String s1 = "13192536473";
        Pattern pattern = null;
        try {
            pattern = Pattern.compile("1[3-9]\\\\d{9}");
        } catch (Exception e) {
            e.printStackTrace();
        }
        Matcher matcher = pattern.matcher(s1);
        if (matcher.matches()) {
            System.out.println("您的手机号" + s1 + "是正确格式@——@");
        } else {
            System.out.println("您的手机号" + s1 + "是错误格式！！！");
        }
    }

/*    public static void timeTest() {
        String expiryTime = "2023-06-08";
        LocalDate expiryLocalTime = LocalDate.parse(expiryTime, DateTimeFormatter.ofPattern(DateUtil.DATE_PATTERN2));
        //当前时间
        LocalDate nowTime = LocalDate.now();

        if (nowTime.getYear() <= expiryLocalTime.getYear()) {
            int monthValue = expiryLocalTime.plusMonths(1).getMonthValue();
            if (nowTime.getMonthValue() < monthValue || monthValue <= 1) {
                //没有到截止日期时间
                System.out.println("没有到截止日期时间 = ");
            } else {
                System.out.println("现在年份大于过期年份111");
            }
        } else {
            System.out.println("现在年份大于过期年份222 ");

        }
    }*/

    public static void stringTest() {
        String string1 = ",张三,李四,王五,马六,小气,";
        String string = "张三";
        //String substring = string.substring(0, string.length());
        //System.out.println(substring);
        String[] split = string.split(",");//以逗号分割
        int i = 0;
        for (String string2 : split) {
            if (StringUtils.isNotBlank(string2)) {
                System.out.println("数据-->>>" + (i++) + "_" + string2);
            }
        }

    }

}
